package com.zy.qudadid.utils;

import android.app.Activity;
import android.content.Intent;
import android.widget.Toast;

import com.yancy.imageselector.ImageConfig;
import com.yancy.imageselector.ImageSelector;
import com.yancy.imageselector.ImageSelectorActivity;
import com.yancy.imageselector.utils.Utils;

/**
 * Created by ninos on 2016/8/29.
 */
public class ImageSelectorUtil extends ImageSelector {

    private static ImageConfig mImageConfig;

    public static void open(Activity activity, ImageConfig config, int requestCode) {
        if (config == null) {
            return;
        }
        mImageConfig = config;

        if (config.getImageLoader() == null) {
            Toast.makeText(activity, com.yancy.imageselector.R.string.open_camera_fail, Toast.LENGTH_SHORT).show();
            return;
        }

        if (!Utils.existSDCard()) {
            Toast.makeText(activity, com.yancy.imageselector.R.string.empty_sdcard, Toast.LENGTH_SHORT).show();
            return;
        }


        Intent intent = new Intent(activity, ImageSelectorActivity.class);
        activity.startActivityForResult(intent, requestCode);
    }
}
